package com.bw;

import cn.hutool.http.useragent.UserAgent;
import cn.hutool.http.useragent.UserAgentUtil;
import org.apache.hadoop.hive.ql.exec.UDF;

import java.util.HashMap;
import java.util.Map;

/**
 * @BelongsProject: ShiXun1_2211B
 * @BelongsPackage: com.bw
 * @Author: zhangleqing
 * @CreateTime: 2025-07-17  08:56
 * @Description: TODO
 * @Version: 1.0
 */
public class uatoregion extends UDF {
    public Map<String, String> evaluate(String user_agent) throws Exception{
        Map<String, String> map = new HashMap<>();

        UserAgent ua = UserAgentUtil.parse(user_agent);

        map.put("browser", ua.getBrowser().toString());
        map.put("browser_version", ua.getVersion());
        map.put("engine", ua.getEngine().toString());
        map.put("engine_version", ua.getEngineVersion());
        map.put("os", ua.getOs().toString());
        map.put("os_version", ua.getOsVersion());
        map.put("platform", ua.getPlatform().toString());
        map.put("is_mobile", ua.isMobile() ? "1" : "0");

        return map;
    }

    public static void main(String[] args) {

    }
}
